﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AviewMotionUI.ProductionStatistics;
using LanCustomControldll;
using FinalTestMachine.Motion.Products;
using FinalTestMachine.Motion;

namespace FinalTestMachine.View.MainUnits
{
    /// <summary>
    /// Unit_ProductInfo.xaml 的交互逻辑
    /// </summary>
    public partial class Unit_StationNGInfo : UserControl, IShow
    {
        public Unit_StationNGInfo()
        {
            InitializeComponent();
        }

        public void ShowUI()
        {
            this.Dispatcher.Invoke(() =>
            {
                tb_NgProductNum1.Text = OtherParamHelper.Cur.Station1_NGNum.GetValue.ToString();
                tb_NgProductNum2.Text = OtherParamHelper.Cur.Station2_NGNum.GetValue.ToString();
                tb_NgProductNum3.Text = OtherParamHelper.Cur.Station3_NGNum.GetValue.ToString();
                tb_NgProductNum4.Text = OtherParamHelper.Cur.Station4_NGNum.GetValue.ToString();
            });
        }

        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to empty the current NG data?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    this.Dispatcher.Invoke(
                        () =>
                        {
                            OtherParamHelper.Cur.Station1_NGNum.GetValue = 0;
                            OtherParamHelper.Cur.Station2_NGNum.GetValue = 0;
                            OtherParamHelper.Cur.Station3_NGNum.GetValue = 0;
                            OtherParamHelper.Cur.Station4_NGNum.GetValue = 0;
                        });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}